/**
 * @program: data_structures_algorithms
 * @description: 线性查找
 * @author: lld
 * @create: 2020-10-13 16:37
 **/
public class SeqSearch {
    public static void main(String[] args) {
        int[] arr={12,435,23,65,34,57,29};
        int search = seqSearch(arr, 9);
        if(search==-1){
            System.out.println("没有找到对应的数");
        }else {
            System.out.println("数的索引："+search);
        }
    }
    public static int seqSearch(int[] arr,int num){
        for(int i=0;i<arr.length;i++){
            if(arr[i]==num){
                return i;
            }
        }
        return -1;
    }
}
